﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using kp.plotter.contract;
using ZedGraph;

namespace kp.plotter
{
    public partial class Plotter : UserControl, IPlotter
    {
        public Plotter()
        {
            InitializeComponent();
        }

        public void ShowPlot(System.Collections.Generic.IEnumerable<System.Drawing.PointF> punkte)
        {
            var PointsToDraw = CreatePointPairList(punkte);
            PlotterGraph.GraphPane.AddCurve("Graph", PointsToDraw, Color.Red, SymbolType.None);
            PlotterGraph.AxisChange();
            PlotterGraph.GraphPane.Draw(CreateGraphics());
            PlotterGraph.Refresh();
        }

        public int Werteanzahl
        {
            get
            {
                return Width;
            }
        }

        private void Plotter_Load(object sender, System.EventArgs e)
        {
            
        }

        internal PointPairList CreatePointPairList(IEnumerable<PointF> mPoints)
        {
            PointPairList List = new PointPairList();

            foreach (var mPoint in mPoints)
            {
                List.Add(mPoint.X, mPoint.Y);
            }

            return List;
        }
    }
}
